﻿<%@ page language="C#" autoeventwireup="true" inherits="Admin_NameEdte, App_Web_nameedte.aspx.fdf7a39c" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/main-admin.css" rel="stylesheet" type="text/css" />

    <script src="../Jscript/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../Jscript/page.js" type="text/javascript"></script>

    <script src="../Jscript/atuo.js" type="text/javascript"></script>

    <script src="../Jscript/jquery-ui-1.7.2.min.js" type="text/javascript"></script>

    <link href="../css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
    <style>
        body
        {
            font-family: Arial;
            font-size: 14px;
            padding: 0px;
            margin: 10px;
        }
        .txt1
        {
            /* 用户输入框的样式 */
            width: 200px;
        }
        #popup
        {
            /* 提示框div块的样式 */
            position: absolute;
            left: 80px;
            top: 32px;
            width: 204px; /*border:solid 1px black;*/
            color: #004a7e;
        }
        #popup.show
        {
            /* 显示提示框的边框 */
            border: 1px solid #004a7e;
        }
        ul
        {
            list-style: none;
            margin: 0px;
            padding: 0px;
            color: #004a7e;
        }
        li.mouseOver
        {
            background-color: #004a7e;
            color: #FFFFFF;
        }
    </style>

    <script type="text/javascript">

        var boolok = 0;

        $(document).ready(function() {

            $("#NameSelect").dialog({
                width: 800,
                height: 450,
                bgiframe: true,
                modal: true,
                autoOpen: false,
                position: ["0", "0"]
            })
        });

        //        var oInputField; //考虑到很多函数中都要使用
        //        var oPopDiv; 	//因此采用全局变量的形式
        //        var oconUl;


        //        $(document).ready(function() {
        //            $(".namevalue").keyup(function() {
        //                oInputField = $(this);
        //                initVars();
        //                findcon();
        //            });



        //        });
        //  

        //        function initVars() {
        //            //初始化变量

        //            oPopDiv = $("#popup");
        //            oconUl = $("#con_ul");
        //        }
        //        function clearcon() {
        //            //清除提示内容
        //            oconUl.empty();
        //            oPopDiv.removeClass("show");
        //        }
        //        function setcon(the_con) {
        //            //显示提示框，传入的参数即为匹配出来的结果组成的数组
        //            clearcon(); //每输入一个字母就先清除原先的提示，再继续
        //            oPopDiv.addClass("show");
        //            for (var i = 0; i < the_con.length; i++)
        //            //将匹配的提示结果逐一显示给用户
        //                oconUl.append($("<li>" + the_con[i] + "</li>"));
        //            oconUl.find("li").click(function() {
        //                oInputField.val($(this).text());
        //                clearcon();
        //            }).hover(
        //		function() { $(this).addClass("mouseOver"); },
        //		function() { $(this).removeClass("mouseOver"); }
        //	);
        //        }
        //        function findcon() {
        //            //初始化变量
        //            if (oInputField.val().length > 0) {
        //                //获取异步数据

        //       
        //                var url = "GetName.ashx?parms=" + oInputField.val();
        //                $.get(url, function(data) {
        //                    var aResult = new Array();
        //                    if (data.length > 0) {
        //                        aResult = data.split(",");
        //                        setcon(aResult); //显示服务器结果
        //                    }
        //                    else
        //                        clearcon();
        //                });
        //            }
        //            else
        //                clearcon(); //无输入时清除提示框（例如用户按del键）


        //        }
        function ToSet(tp) {


            switch (tp) {
                case "name":
                    var v = $(".namevalue:first").val();

                    $(".namevalue:even").val(v);

                    break;
                case "num":
                    var v = $(".numvalue:first").val();

                    $(".numvalue:even").val(v);

                    break;
                case "weight":
                    var v = $(".weightvalue:first").val();

                    $(".weightvalue:even").val(v);
                    break;
            }





        }


        function ToEdit() {


            var id = ",";
            var tno = ",";
            var name = "|";
            var num = ",";
            var price = ",";
            var ok = false;
            $(".namevalue").each(function() {

                var obj = $(this);


                id = id + obj.attr("id").replace("name", "") + ",";
                tno = tno + obj.attr("title") + ",";

                name = name + obj.val().replace(",", "，") + "|";

                if ($.trim(obj.val()) != "") {
                    ok = true;
                }

            });

            if (!ok) {


                OpenWindow("请录入货物资料后在点击保存");
                return;


            }
            $(".numvalue").each(function() {

                var obj = $(this);

                num = num + obj.val() + ",";


            });
            $(".weightvalue").each(function() {

                var obj = $(this);

                price = price + obj.val() + ",";


            });

            //            OpenWindow(id + "<br/>" + tno + "<br/>" + name);
            //            return;

            OpenWindow("数据更新中....请务重复点击，关闭");
            $.post("NameEdte.ashx", { aid: id, atno: tno, aname: name, anum: num, aprice: price }, function(data) {


                if (data == "ok") {
                    OpenWindow("全部编辑成功！请继续");
                    boolok = 1;
                }
                else {
                    OpenWindow(data);

                }
            });


        }


        var newtage = "";
        function EditValue(tag) {


            newtage = tag
            ToEdit();
            window.setInterval("ToUrl()", 500); //启动1秒定时 

        }


        function ToUrl() {
            if (boolok == 1) {
                var tnvalue = GetQueryString("no");
                if (tnvalue == "") {
                    alert("参数异常！请关闭重试！");
                }
                switch (newtage) {
                    case "name":
                        window.location = "NameEdte.aspx?no=" + tnvalue;
                        break;
                    case "logo":
                        window.location = "BillLogoPl.aspx?no=" + tnvalue;
                        break;
                    case "other":
                        window.location = "OtherEdit.aspx?no=" + tnvalue;
                        break;
                    case "price":
                        window.location = "PriceEdit.aspx?no=" + tnvalue;
                        break;


                }
            }

        }
        function GetQueryString(name) {

            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");

            var r = window.location.search.substr(1).match(reg);

            if (r != null) return unescape(r[2]); return null;

        }


        var ntype = "";

        function ShowNameSelect(type) {
            ntype = type;

            $("input[type=checkbox]").each(function() {

                if ($(this).attr("checked") == true) {

                    if ($(this).attr("name") == "toselectnameck") {
                        $(this).attr("checked", false);
                    }
                }
            });

            $("#NameSelect").dialog('open');
        }


        function ToNameSelect() {

            var select = ""
            $("input[type=checkbox]").each(function() {

                if ($(this).attr("checked") == true) {

                    if ($(this).attr("name") == "toselectnameck") {

                        select += "," + $(this).val();
                    }
                }
            });





            var nv = $("input[name='txtname" + ntype + "']").val();
      
            $("input[name='txtname" + ntype + "']").val(nv + select);
            $("#NameSelect").dialog('close');
        }

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="title">
        批量品名编辑</div>
    <div class="trans-search-title">
        <div class="trans-edit-no">
            货运单号</div>
        <div class="trans-edit-item">
            货物品名
            <img src="../images/arr-down-s.gif" width="13" height="13" align="absmiddle" onclick="ToSet('name')" /></div>
        <div class="trans-edit-qty">
            数量
            <img src="../images/arr-down-s.gif" width="13" height="13" align="absmiddle" onclick="ToSet('num')" /></div>
        <div class="trans-edit-weight">
            海关申报价
            <img src="../images/arr-down-s.gif" width="13" height="13" align="absmiddle" onclick="ToSet('weight')" /></div>
    </div>
    <asp:Repeater ID="list" runat="server">
        <ItemTemplate>
            <%#(Container.ItemIndex + 1) % 2 == 0 ? "<div  id=\"div" + Container.ItemIndex + "\"  class=\"trans-search-line\" style=\"background-color:#eeeee8;height:50px\">" : "<div   id=\"div" + Container.ItemIndex + "\"  class=\"trans-search-line\" style=\";height:50px\">"%>
            <div class="trans-edit-no">
                <a href="trans-detail.html">
                    <asp:Label ID="no_txt" Text='<%#Eval("Sep").ToString() == "True"?"Sep":""%>' runat="server"
                        ForeColor="Red"></asp:Label>
                    <%#Eval("No")%>
                </a>
            </div>
            <div style="float: left">
                <div class="trans-edit-item">
                    <img src="../Images/insertname.jpg" border="0" align="absmiddle" onclick='ShowNameSelect(<%#Container.ItemIndex+1%>)' />
                    <input type="text" name='txtname<%#Container.ItemIndex+1%>' id='name<%#Getid(Eval("No").ToString(),1,0)%>'  
                        class="namevalue" title='<%#Eval("No")%>' value='<%#Getid(Eval("No").ToString(),2,0)%>'
                        style="width: 540px; border: 1px solid #CCC; height: 15px;" /></div>
                <div class="trans-edit-qty">
                    <input type="text" name="textfield2" id='num<%#Getid(Eval("No").ToString(),1,0)%>'
                        class="numvalue" value='<%#Getid(Eval("No").ToString(),3,0)%>' style="width: 80px;
                        border: 1px solid #CCC; height: 15px;" /></div>
                <div class="trans-edit-weight">
                    <input type="text" name="textfield2" id='weight<%#Getid(Eval("No").ToString(),1,0)%>'
                        class="weightvalue" value='<%#Getid(Eval("No").ToString(),4,0)%>' style="width: 80px;
                        border: 1px solid #CCC; height: 15px;" /></div>
                <div style="clear: both;">
                </div>
                <div class="trans-edit-item" style="margin-top: 2px; margin-bottom: 5px;">
                    <img src="../Images/insertname.jpg" border="0" align="absmiddle" onclick='ShowNameSelect(<%#Container.ItemIndex+2%>)' />
                    <input type="text"  name='txtname<%#Container.ItemIndex+2%>' id='name<%#Getid(Eval("No").ToString(),1,1)%>'
                        title='<%#Eval("No")%>' class="namevalue" value='<%#Getid(Eval("No").ToString(),2,1)%>'
                        style="width: 540px; border: 1px solid #CCC; height: 15px;" /></div>
                <div class="trans-edit-qty" style="margin-top: 2px; margin-bottom: 5px">
                    <input type="text" name="textfield2" id='num<%#Getid(Eval("No").ToString(),1,1)%>'
                        class="numvalue" value='<%#Getid(Eval("No").ToString(),3,1)%>' style="width: 80px;
                        border: 1px solid #CCC; height: 15px;" /></div>
                <div class="trans-edit-weight" style="margin-top: 2px; margin-bottom: 5px">
                    <input type="text" name="textfield2" id='weight<%#Getid(Eval("No").ToString(),1,1)%>'
                        class="weightvalue" value='<%#Getid(Eval("No").ToString(),4,1)%>' style="width: 80px;
                        border: 1px solid #CCC; height: 15px;" /></div>
            </div>
            </div>
        </ItemTemplate>
    </asp:Repeater>
    备注：分单单据前缀为红色：<span style="color: Red">Sep</span>
    <div style="color: #606; font-weight: bold; float: left; width: 966px; margin-top: 20px;
        text-align: center;">
        <div style="width: 100%; text-align: right">
            <div style="margin: 10px 0px 0px 3px;">
                <img src="../images/arrow-up.gif" width="25" height="24" />
                &nbsp;
                <img src="../images/btn-pricelot.gif" width="68" height="25" border="0" onclick="EditValue('price')" />
                &nbsp;
                <img src="../images/btn-otherlot.gif" width="68" height="25" border="0" onclick="EditValue('other')" />
                &nbsp;
                <img src="../images/btn-pringlogolot.gif" width="68" height="25" border="0" onclick="EditValue('logo')" />
                &nbsp;&nbsp;
            </div>
        </div>
        <img src="../images/btn-save-trans.gif" width="192" height="40" onclick="ToEdit()" />
    </div>
    <div id="auto" style="height: 250px; overflow: scroll">
    </div>
    <div id="NameSelect" title="品名选择">
        <div style="width: 100%; text-align: center">
            <img src="../Images/okinsert.jpg" border="0" align="absmiddle" onclick="ToNameSelect()" />
            <br />
            <br />
        </div>
        <asp:Repeater ID="Rpt_Name" runat="server">
            <ItemTemplate>
                <input type="checkbox" id="nameck" name="toselectnameck" value='<%#Eval("GoodsName")%>' />
                <%#Eval("GoodsName")%>
                <%#(((Container.ItemIndex + 1) % 9) == 0) ? "<br/><br/>" : ""%>
            </ItemTemplate>
        </asp:Repeater>
    </div>
    </form>
</body>
</html>
